<?php
namespace app\common\validate;



use app\lib\exception\BaseException;
use think\Validate;

class BaseValidate extends Validate
{
    /**
     * 验证参数是否满足要求
     * @param $scene
     * @return true
     * @throws BaseException
     */
    public function goCheck($scene="")
    {
        //获取所有请求参数
        $params = request()->param();
        //验证
        $check = empty($scene) ?
            $this->check($params):
            $this->scene($scene)->check($params);
        if(!$check){
            $arr = [
                'code' => 400,
                'errorCode' => 10000,
                'msg' => is_array($this->error) ? implode(';',$this->error) : $this->error
            ];
            throw (new BaseException($arr));
        }
        return true;
    }
}